//
//  IndividualTableViewController.m
//  EasyToTesco2.0
//
//  Created by 袖手旁觀 on 16/6/21.
//  Copyright © 2016年 EasyToTesco. All rights reserved.
//

#import "IndividualTableViewController.h"
#import "TotalRecordViewController.h"
#import "StandingsConvertTableViewController.h"

@interface IndividualTableViewController ()

@property (nonatomic,strong)NSArray *individual;


@end

static NSString *const reuseIdentifier = @"Identifier";

@implementation IndividualTableViewController

- (NSArray *)individual {
    if (!_individual) {
        _individual = @[@"代金券兑换",@"消费记录"];
    }
    return _individual;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
    
    if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
        
        [self.tableView setSeparatorInset:UIEdgeInsetsMake(0, -25, 0, 0)];
        
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"个人专区";
    
    self.tableView.backgroundColor = BACKGROUND_COLOR;
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.tableView.tableFooterView = [[UIView alloc] init];
}

#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.individual.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    //12
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.textLabel.font = FONT(15);
    }
    
    cell.textLabel.text = self.individual[indexPath.row];
    return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSLog(@"%ld",indexPath.row);
    
    if (indexPath.row == 1) {
        TotalRecordViewController *total = [[TotalRecordViewController alloc] init];
        [self.navigationController pushForm:self.navigationController pushToAndHidden:total];
    }
    
    if (indexPath.row == 0) {
        StandingsConvertTableViewController *stand = [[StandingsConvertTableViewController alloc] init];
        stand.voucherStr = self.voucherStr;
        [self.navigationController pushForm:self.navigationController pushToAndHidden:stand];
    }
}


@end
